var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
    })(t, e);
}, function(t, e) {
    function i() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (i.prototype = e.prototype, 
    new i());
}), a = this && this.__decorate || function(t, e, o, i) {
    var n, r = arguments.length, c = r < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) c = Reflect.decorate(t, e, o, i); else for (var l = t.length - 1; 0 <= l; l--) (n = t[l]) && (c = (r < 3 ? n(c) : 3 < r ? n(e, o, c) : n(e, o)) || c);
    return 3 < r && c && Object.defineProperty(e, o, c), c;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("GameConfig"), s = e("VideoItemView"), c = e("VideoTopItemView"), l = cc._decorator, d = l.ccclass, u = l.property, p = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.top = null, t.scrollView = null, t.itemPrefab = null, t.items = [], t;
    }
    return i(t, e), t.prototype.onScrollow = function() {
        var o = this;
        this.items.forEach(function(t, e) {
            2 < e && (t.node.y + o.scrollView.content.y > t.node.height / 2 || Math.abs(t.node.y + o.scrollView.content.y) > o.scrollView.node.height + t.node.height / 2 ? t.node.active = !1 : t.node.active = !0);
        });
    }, t.prototype.init = function() {
        this.items = this.top.getComponentsInChildren(c.default), this.items.forEach(function(t, e) {
            e < r.GC.videoLikeList.length && (t.init(r.GC.videoLikeList[e]), t.bind());
        });
        for (var t = 0; this.items.length < r.GC.videoLikeList.length; ) {
            var e = Math.floor(t / 4), o = t % 4, i = cc.instantiate(this.itemPrefab);
            i.parent = this.scrollView.content, i.x = o * i.width + (i.width / 2 - this.scrollView.content.width / 2), 
            i.y = -e * i.height - i.height / 2;
            e = i.getComponent(s.default);
            this.items.push(e), e.init(r.GC.videoLikeList[this.items.length - 1]), e.bind(), 
            t++, this.scrollView.content.height = Math.ceil(t / 4) * i.height;
        }
        this.onScrollow();
    }, a([ u(cc.Node) ], t.prototype, "top", void 0), a([ u(cc.ScrollView) ], t.prototype, "scrollView", void 0), 
    a([ u(cc.Prefab) ], t.prototype, "itemPrefab", void 0), a([ d ], t);
}(cc.Component);

n.default = p;